package com.ymatou.iapi.coupon.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import jdk.nashorn.internal.ir.annotations.Ignore;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.coupon.parameter.userReceiveCouponBagBean;
import com.ymatou.iapi.coupon.service.userReceiveCouponBagCall;
import com.ymatou.iapi.couponmanage.parameter.BatchInfo;
import com.ymatou.iapi.couponmanage.parameter.CreateBagBean;
import com.ymatou.iapi.couponmanage.parameter.CreateBean;
import com.ymatou.iapi.couponmanage.parameter.CreateCouponBean;
import com.ymatou.iapi.couponmanage.service.CreateBagCall;
import com.ymatou.iapi.couponmanage.service.CreateCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponServiceMCallServiceV2;
import com.ymttest.database.model.coupon;
import com.ymttest.database.model.couponbag;
import com.ymttest.database.model.couponbatch;
import com.ymttest.database.model.couponupdatesetting;
import com.ymttest.database.sqlwapper.couponWapper;
import com.ymttest.database.sqlwapper.couponbagWapper;
import com.ymttest.database.sqlwapper.couponbatchWapper;
import com.ymttest.database.sqlwapper.couponupdatesettingWapper;
import com.ymttest.utils.EnvSetup;
/**
*领取套券
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_userReceiveCouponBag{
	private static userReceiveCouponBagBean userreceivecouponbagBean;
	private static userReceiveCouponBagCall userreceivecouponbagCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("领取套券");
	}

	@Before
	public void caseUp() {
		userreceivecouponbagBean=new userReceiveCouponBagBean();
		userreceivecouponbagCall=new userReceiveCouponBagCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(userreceivecouponbagCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_userReceiveCouponBag_001() {
		Logger.start(true,"领取套券");
		try {
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			
			couponbag beforBag = new couponbagWapper().selectByPrimaryKey(createBagCall.getbagCode());
			List<couponbatch> beforBatchlst = new couponbatchWapper().getCouponBatchByBagCode(createBagCall.getbagCode());
			userreceivecouponbagBean.setUserId(Integer.valueOf(EnvSetup
					.getData("BuyUserId")));
			userreceivecouponbagBean.setUserType(0);
			userreceivecouponbagBean.setCouponBagCode(createBagCall.getbagCode());
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();		
			VerifyReturn(createBagBean,createBagCall,beforBatchlst,beforBag);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_userReceiveCouponBag_002() {
		Logger.start(true,"领取套券-多个批次-不限用户");
		try {
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			List<BatchInfo> BatchInfos=new ArrayList<BatchInfo>();
			BatchInfo info=new BatchInfo();
			info.setCouponName("自动化创建套券优惠券名称-子套券");
			info.setCouponDes("自动化创建套券优惠券描述-子套券");
			info.setApplyMemo("自动化创建申请理由-子套券");
			info.setOrderMinAmount(new BigDecimal(2));
			info.setDeductionMaxAmount(new BigDecimal(1));
			List<String> productIds = new ArrayList<String>();
			info.setProductIds(productIds);
			List<Integer> SellerIds = new ArrayList<Integer>();
			info.setSellerIds(SellerIds);
			List<Integer> ActivityIds = new ArrayList<Integer>();
			info.setActivityIds(ActivityIds);
			List<Integer> Brands = new ArrayList<Integer>();
			info.setBrands(Brands);
			List<Integer> Countrys = new ArrayList<Integer>();
			info.setCountrys(Countrys);
			List<Integer> Categories = new ArrayList<Integer>();
			info.setCategories(Categories);
			info.setLimitPspProduct(false);
			BatchInfos.add(info);
			BatchInfos.add(info);
			createBagBean.setBatchInfos(BatchInfos);
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			
			couponbag beforBag = new couponbagWapper().selectByPrimaryKey(createBagCall.getbagCode());
			List<couponbatch> beforBatchlst = new couponbatchWapper().getCouponBatchByBagCode(createBagCall.getbagCode());
			
			userreceivecouponbagBean.setUserId(Integer.valueOf(EnvSetup
					.getData("BuyUserId")));
			//0:未知1:新用户2:老用户
			userreceivecouponbagBean.setUserType(0);
			userreceivecouponbagBean.setCouponBagCode(createBagCall.getbagCode());
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();		
			
			VerifyReturn(createBagBean,createBagCall,beforBatchlst,beforBag);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_userReceiveCouponBag_003() {
		Logger.start(true,"领取套券-多个批次-新用户");
		try {
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			List<BatchInfo> BatchInfos=new ArrayList<BatchInfo>();
			BatchInfo info=new BatchInfo();
			info.setCouponName("自动化创建套券优惠券名称-子套券");
			info.setCouponDes("自动化创建套券优惠券描述-子套券");
			info.setApplyMemo("自动化创建申请理由-子套券");
			info.setOrderMinAmount(new BigDecimal(2));
			info.setDeductionMaxAmount(new BigDecimal(1));
			List<String> productIds = new ArrayList<String>();
			info.setProductIds(productIds);
			List<Integer> SellerIds = new ArrayList<Integer>();
			info.setSellerIds(SellerIds);
			List<Integer> ActivityIds = new ArrayList<Integer>();
			info.setActivityIds(ActivityIds);
			List<Integer> Brands = new ArrayList<Integer>();
			info.setBrands(Brands);
			List<Integer> Countrys = new ArrayList<Integer>();
			info.setCountrys(Countrys);
			List<Integer> Categories = new ArrayList<Integer>();
			info.setCategories(Categories);
			info.setLimitPspProduct(false);
			BatchInfos.add(info);
			BatchInfos.add(info);
			createBagBean.setBatchInfos(BatchInfos);
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			
			couponbag beforBag = new couponbagWapper().selectByPrimaryKey(createBagCall.getbagCode());
			List<couponbatch> beforBatchlst = new couponbatchWapper().getCouponBatchByBagCode(createBagCall.getbagCode());
			
			userreceivecouponbagBean.setUserId(Integer.valueOf(EnvSetup
					.getData("BuyUserId")));
			//0:未知1:新用户2:老用户
			userreceivecouponbagBean.setUserType(1);
			userreceivecouponbagBean.setCouponBagCode(createBagCall.getbagCode());
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();		
			
			VerifyReturn(createBagBean,createBagCall,beforBatchlst,beforBag);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_userReceiveCouponBag_004() {
		Logger.start(true,"领取套券-多个批次-老用户");
		try {
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			List<BatchInfo> BatchInfos=new ArrayList<BatchInfo>();
			BatchInfo info=new BatchInfo();
			info.setCouponName("自动化创建套券优惠券名称-子套券");
			info.setCouponDes("自动化创建套券优惠券描述-子套券");
			info.setApplyMemo("自动化创建申请理由-子套券");
			info.setOrderMinAmount(new BigDecimal(2));
			info.setDeductionMaxAmount(new BigDecimal(1));
			List<String> productIds = new ArrayList<String>();
			info.setProductIds(productIds);
			List<Integer> SellerIds = new ArrayList<Integer>();
			info.setSellerIds(SellerIds);
			List<Integer> ActivityIds = new ArrayList<Integer>();
			info.setActivityIds(ActivityIds);
			List<Integer> Brands = new ArrayList<Integer>();
			info.setBrands(Brands);
			List<Integer> Countrys = new ArrayList<Integer>();
			info.setCountrys(Countrys);
			List<Integer> Categories = new ArrayList<Integer>();
			info.setCategories(Categories);
			info.setLimitPspProduct(false);
			BatchInfos.add(info);
			BatchInfos.add(info);
			createBagBean.setBatchInfos(BatchInfos);
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			
			couponbag beforBag = new couponbagWapper().selectByPrimaryKey(createBagCall.getbagCode());
			List<couponbatch> beforBatchlst = new couponbatchWapper().getCouponBatchByBagCode(createBagCall.getbagCode());
			
			userreceivecouponbagBean.setUserId(Integer.valueOf(EnvSetup
					.getData("BuyUserId")));
			//0:未知1:新用户2:老用户
			userreceivecouponbagBean.setUserType(2);
			userreceivecouponbagBean.setCouponBagCode(createBagCall.getbagCode());
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();		
			
			VerifyReturn(createBagBean,createBagCall,beforBatchlst,beforBag);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_userReceiveCouponBag_005() {
		Logger.start(true,"领取套券-单个批次-不限用户");
		try {
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			
			couponbag beforBag = new couponbagWapper().selectByPrimaryKey(createBagCall.getbagCode());
			List<couponbatch> beforBatchlst = new couponbatchWapper().getCouponBatchByBagCode(createBagCall.getbagCode());
			
			userreceivecouponbagBean.setUserId(Integer.valueOf(EnvSetup
					.getData("BuyUserId")));
			//0:未知1:新用户2:老用户
			userreceivecouponbagBean.setUserType(0);
			userreceivecouponbagBean.setCouponBagCode(createBagCall.getbagCode());
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();		
			
			VerifyReturn(createBagBean,createBagCall,beforBatchlst,beforBag);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_userReceiveCouponBag_006() {
		Logger.start(true,"领取套券-单个批次-新用户");
		try {
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			
			couponbag beforBag = new couponbagWapper().selectByPrimaryKey(createBagCall.getbagCode());
			List<couponbatch> beforBatchlst = new couponbatchWapper().getCouponBatchByBagCode(createBagCall.getbagCode());
			
			userreceivecouponbagBean.setUserId(Integer.valueOf(EnvSetup
					.getData("BuyUserId")));
			//0:未知1:新用户2:老用户
			userreceivecouponbagBean.setUserType(1);
			userreceivecouponbagBean.setCouponBagCode(createBagCall.getbagCode());
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();		
			
			VerifyReturn(createBagBean,createBagCall,beforBatchlst,beforBag);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_userReceiveCouponBag_007() {
		Logger.start(true,"领取套券-单个批次-老用户");
		try {
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			
			couponbag beforBag = new couponbagWapper().selectByPrimaryKey(createBagCall.getbagCode());
			List<couponbatch> beforBatchlst = new couponbatchWapper().getCouponBatchByBagCode(createBagCall.getbagCode());
			
			userreceivecouponbagBean.setUserId(Integer.valueOf(EnvSetup
					.getData("BuyUserId")));
			//0:未知1:新用户2:老用户
			userreceivecouponbagBean.setUserType(2);
			userreceivecouponbagBean.setCouponBagCode(createBagCall.getbagCode());
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();		
			
			VerifyReturn(createBagBean,createBagCall,beforBatchlst,beforBag);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_userReceiveCouponBag_008() {
		Logger.start(true,"领取套券-直接领取");
		try {
			//TODO 补全case代码
			org.junit.Assert.fail();
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_userReceiveCouponBag_009() {
		Logger.start(true,"领取套券-兑换");
		try {
			//TODO 补全case代码
			org.junit.Assert.fail();
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_userReceiveCouponBag_010() {
		Logger.start(true,"领取套券-不在领取时间范围");
		try {
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			couponbatch beforBatch = new couponbatchWapper().getCouponBatchByBagCode(createBagCall.getbagCode()).get(0);
			
			Date dNow = new Date(); // 当前时间
	        Date dBefore = new Date();
	        Date dAfter = new Date();

	        Calendar calendar1 = Calendar.getInstance(); // 得到日历
	        calendar1.setTime(dNow);// 把当前时间赋给日历
	        calendar1.add(Calendar.DAY_OF_MONTH, -10); // 设置为前一天
	        dBefore = calendar1.getTime(); // 得到前一天的时间

	        Calendar calendar2 = Calendar.getInstance(); // 得到日历
	        calendar2.setTime(dNow);// 把当前时间赋给日历
	        calendar2.add(Calendar.DAY_OF_MONTH, -1); // 设置为后十天
	        dAfter = calendar2.getTime(); // 得到前一天的时间
	        new couponbatchWapper().setAcquireStartTime(beforBatch.getBatchCode(), dBefore);
	    	new couponbatchWapper().setAcquireEndTime(beforBatch.getBatchCode(), dAfter);
	        
			userreceivecouponbagBean.setUserId(Integer.valueOf(EnvSetup
					.getData("BuyUserId")));
			//0:未知1:新用户2:老用户
			userreceivecouponbagBean.setUserType(0);
			userreceivecouponbagBean.setCouponBagCode(createBagCall.getbagCode());
			
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();	

			Logger.verifyEquals("0", userreceivecouponbagCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", userreceivecouponbagCall.getMessage(), "验证返回Message");
			Logger.verifyEquals(false, userreceivecouponbagCall.getsuccess(), "验证返回data中的success字段");
			Logger.verifyEquals(14, userreceivecouponbagCall.getfailReason(), "验证返回data中的failReason字段");
			Logger.verifyEquals("超出领取结束时间", userreceivecouponbagCall.getfailReasonDes(), "验证返回data中的failReasonDes字段");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_userReceiveCouponBag_011() {
		Logger.start(true,"领取套券-批次不能用于领取");
		try {
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			createBagBean.setAcquireMethod(2);
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);

			userreceivecouponbagBean.setUserId(Integer.valueOf(EnvSetup
					.getData("BuyUserId")));
			//0:未知1:新用户2:老用户
			userreceivecouponbagBean.setUserType(0);
			userreceivecouponbagBean.setCouponBagCode(createBagCall.getbagCode());
			
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();	

			Logger.verifyEquals("0", userreceivecouponbagCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", userreceivecouponbagCall.getMessage(), "验证返回Message");
			Logger.verifyEquals(false, userreceivecouponbagCall.getsuccess(), "验证返回data中的success字段");
			Logger.verifyEquals(19, userreceivecouponbagCall.getfailReason(), "验证返回data中的failReason字段");
			Logger.verifyEquals("批次不能用于领取", userreceivecouponbagCall.getfailReasonDes(), "验证返回data中的failReasonDes字段");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_userReceiveCouponBag_012() {
		Logger.start(true,"领取套券-批次不存在");
		try {
			userreceivecouponbagBean.setUserId(Integer.valueOf(EnvSetup
					.getData("BuyUserId")));
			//0:未知1:新用户2:老用户
			userreceivecouponbagBean.setUserType(0);
			userreceivecouponbagBean.setCouponBagCode("99999");
			
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();			
			
			Logger.verifyEquals("0", userreceivecouponbagCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", userreceivecouponbagCall.getMessage(), "验证返回Message");
			Logger.verifyEquals(false, userreceivecouponbagCall.getsuccess(), "验证返回data中的success字段");
			Logger.verifyEquals(8, userreceivecouponbagCall.getfailReason(), "验证返回data中的failReason字段");
			Logger.verifyEquals("批次不存在", userreceivecouponbagCall.getfailReasonDes(), "验证返回data中的failReasonDes字段");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_userReceiveCouponBag_013() {
		Logger.start(true,"领取套券-已领用");
		try {
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			
			userreceivecouponbagBean.setUserId(Integer.valueOf(EnvSetup
					.getData("BuyUserId")));
			userreceivecouponbagBean.setUserType(0);
			userreceivecouponbagBean.setCouponBagCode(createBagCall.getbagCode());
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			//第一次领完
			userreceivecouponbagCall.callService();
			//第二次超出领取
			userreceivecouponbagCall.callService();	
			
			Logger.verifyEquals("0", userreceivecouponbagCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", userreceivecouponbagCall.getMessage(), "验证返回Message");
			Logger.verifyEquals(false, userreceivecouponbagCall.getsuccess(), "验证返回data中的success字段");
			Logger.verifyEquals(2, userreceivecouponbagCall.getfailReason(), "验证返回data中的failReason字段");
			Logger.verifyEquals("用户超出领取数", userreceivecouponbagCall.getfailReasonDes(), "验证返回data中的failReasonDes字段");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_userReceiveCouponBag_014() {
		Logger.start(true,"领取套券-userId为空");
		try {
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			//userreceivecouponbagBean.setUserId(Integer.valueOf(EnvSetup.getData("BuyUserId")));
			//0:未知1:新用户2:老用户
			userreceivecouponbagBean.setUserType(0);
			userreceivecouponbagBean.setCouponBagCode(createBagCall.getbagCode());
			
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();			
			
//			Logger.verifyEquals("0", userreceivecouponbagCall.getCode(), "验证返回code");
//			Logger.verifyEquals("操作成功！", userreceivecouponbagCall.getMessage(), "验证返回Message");
//			Logger.verifyEquals(false, userreceivecouponbagCall.getsuccess(), "验证返回data中的success字段");
//			Logger.verifyEquals(8, userreceivecouponbagCall.getfailReason(), "验证返回data中的failReason字段");
//			Logger.verifyEquals("批次不存在", userreceivecouponbagCall.getfailReasonDes(), "验证返回data中的failReasonDes字段");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_userReceiveCouponBag_015() {
		Logger.start(true,"领取套券-couponBagCode为空");
		try {
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			createBagBean.setAcquireMethod(2);
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);

			userreceivecouponbagBean.setUserId(Integer.valueOf(EnvSetup
					.getData("BuyUserId")));
			//0:未知1:新用户2:老用户
			userreceivecouponbagBean.setUserType(0);
			userreceivecouponbagBean.setCouponBagCode(null);
			
			userreceivecouponbagCall.setData(userreceivecouponbagBean);
			userreceivecouponbagCall.callService();	

			Logger.verifyEquals("1", userreceivecouponbagCall.getCode(), "验证返回code");
			Logger.verifyEquals(true, userreceivecouponbagCall.getMessage().contains("couponBagCode:conversionCode must not be blank"), "验证返回Message");
//			Logger.verifyEquals(false, userreceivecouponbagCall.getsuccess(), "验证返回data中的success字段");
//			Logger.verifyEquals(19, userreceivecouponbagCall.getfailReason(), "验证返回data中的failReason字段");
//			Logger.verifyEquals("批次不能用于领取", userreceivecouponbagCall.getfailReasonDes(), "验证返回data中的failReasonDes字段");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	private void VerifyReturn(CreateBagBean createBagBean,CreateBagCall createBagCall,List<couponbatch> beforBatchs,couponbag beforBag) throws InterruptedException
	{

		
		Logger.verifyEquals("0", userreceivecouponbagCall.getCode(), "验证返回code");
		Logger.verifyEquals("操作成功！", userreceivecouponbagCall.getMessage(), "验证返回Message");
		Logger.verifyEquals(true, userreceivecouponbagCall.getsuccess(), "验证返回data中的success字段");
		Logger.verifyEquals(0, userreceivecouponbagCall.getfailReason(), "验证返回data中的failReason字段");
		Logger.verifyEquals("成功", userreceivecouponbagCall.getfailReasonDes(), "验证返回data中的failReasonDes字段");
		//验证数据库
		List<couponbatch> afterBatchlst = new couponbatchWapper().getCouponBatchByBagCode(createBagCall.getbagCode());
		couponbag afterBag = new couponbagWapper().selectByPrimaryKey(createBagCall.getbagCode());
		for(int i=0;i<afterBatchlst.size();i++)
		{
			int count=i+1;
			coupon coupon = new couponWapper().selectByBatchId(afterBatchlst.get(i).getBatchId()).get(0);
			Logger.verifyEquals(1,afterBatchlst.get(i).getReceivedCount()-beforBatchs.get(i).getReceivedCount(), "验证couponbatch表中第"+count+"条的getReceivedCount值加1");
			Logger.verifyEquals(1, afterBag.getReceivedCount()-beforBag.getReceivedCount(), "验证couponbag表中第"+count+"条的ReceivedCount值加1");
			Logger.verifyEquals(false,coupon.getIsUsed(), "验证coupon表中第"+count+"条的IsUsed字段");
			Logger.verifyEquals(afterBatchlst.get(i).getBagCode(),coupon.getBagCode(), "验证couponBatch表和coupon表中的BagCode是否相同");
			Logger.verifyEquals(userreceivecouponbagBean.getCouponBagCode(),coupon.getBagCode(), "验证coupon表中的BagCode是否与请求报文中相同");
			Logger.verifyEquals(userreceivecouponbagBean.getUserId(),coupon.getUserId(), "验证coupon表中的UserId是否与请求报文中相同");
		}
	}
}